package plus.chendd.lock;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

public class CyclicBarrierTest001 {
  public static void main(String[] args) {
    CyclicBarrier t1 = new CyclicBarrier(20, () -> {
      System.out.println("满人，一次发车");
    });
    
    for (int i = 0; i < 100; i++) {
      new Thread(() -> {
        try {
          t1.await();
        } catch (InterruptedException e) {
          throw new RuntimeException(e);
        } catch (BrokenBarrierException e) {
          throw new RuntimeException(e);
        }
      }).start();
    }
  }
}
